package com.liu.stockmarket.ui.weight

import android.annotation.SuppressLint
import android.content.Context
import android.widget.TextView
import com.github.mikephil.charting.components.MarkerView
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.highlight.Highlight
import com.github.mikephil.charting.utils.MPPointF
import com.liu.stockmarket.R

/**
 * 图标的提示
 */
@SuppressLint("ViewConstructor")
class TipMarkerView(context: Context, private val markerText: (e: Entry) -> String) :
    MarkerView(context, R.layout.custom_marker_view) {
    override fun refreshContent(e: Entry, highlight: Highlight) {
        findViewById<TextView>(R.id.tvContent).text = markerText.invoke(e)
        super.refreshContent(e, highlight)

    }

    override fun getOffset(): MPPointF {
        return MPPointF(-(width / 2).toFloat(), -height.toFloat())
    }
}